---
title: Collapsible
description: An interactive component that expands/collapses a panel.
shadcnDocsLink: https://ui.shadcn.com/docs/components/collapsible
---

<ComponentPreview component="collapsible">
  ```tsx file=<rootDir>/src/examples/ui/collapsible.tsx
  ```
</ComponentPreview>

## Installation

<Installation component="collapsible">
  ```tsx file=<rootDir>/src/components/ui/collapsible.tsx
  ```
</Installation>

## Usage

```ts
import { ChevronsUpDown } from "lucide-react"

import * as React from "react"

import { Button } from "@/components/ui/button"
import {
  Collapsible,
  CollapsibleContent,
  CollapsibleTrigger,
} from "@/components/ui/collapsible"
```

```tsx
const [isOpen, setIsOpen] = React.useState(false)
```


```tsx
<Collapsible
  open={isOpen}
  onOpenChange={setIsOpen}
  className="w-[350px] space-y-2"
>
  <div className="rounded-base flex items-center justify-between space-x-4 border-2 border-border text-main-foreground bg-main px-4 py-2">
    <h4 className="text-sm font-heading">
      @peduarte starred 3 repositories
    </h4>
    <CollapsibleTrigger asChild>
      <Button
        variant="noShadow"
        size="sm"
        className="w-9 bg-secondary-background text-foreground p-0"
      >
        <ChevronsUpDown className="size-4" />
        <span className="sr-only">Toggle</span>
      </Button>
    </CollapsibleTrigger>
  </div>
  <div className="rounded-base border-2 border-border bg-main px-4 py-3 font-mono font-base text-main-foreground text-sm">
    @radix-ui/primitives
  </div>
  <CollapsibleContent className="space-y-2 text-main-foreground font-base">
    <div className="rounded-base border-2 border-border bg-main px-4 py-3 font-mono text-sm">
      @radix-ui/colors
    </div>
    <div className="rounded-base border-2 border-border bg-main px-4 py-3 font-mono text-sm">
      @stitches/react
    </div>
  </CollapsibleContent>
</Collapsible>
```